//
//  GGXiuViewController.m
//  Gunterapple
//
//  Created by 热带雨林 on 2020/4/2.
//  Copyright © 2020 热带雨林. All rights reserved.
//

#import "GGXiuViewController.h"
#import "GGAddtion.h"
@interface GGXiuViewController ()
@property (nonatomic, strong) UIButton *xiuBtn;
@end

@implementation GGXiuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"咻一咻！";
    self.view.backgroundColor = [UIColor whiteColor];
    [self views];
    
    self.xiuBtn = [[UIButton alloc]init];
    [self.xiuBtn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.xiuBtn];
    [self.xiuBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(100, 100));
    }];
    
}
- (void)clickBtn:(UIButton *)sender{
    sender.enabled = YES;
    __block NSInteger count = 0;
    for (NSInteger i = 0; i < 6; i ++) {
        UIView *view = [self views];
        [UIView animateWithDuration:5 delay:i*0.5 options:0 animations:^{
            view.transform = CGAffineTransformMakeScale(8, 8);
            view.alpha = 0;
        } completion:^(BOOL finished) {
            [view removeFromSuperview];
            count ++;
            if(count == 8){
                sender.enabled = YES;
            }
        }];
    }
}

- (UIView *)views{
    UIView *view = [[UIView alloc]init];
    view.center = self.view.center;
    view.bounds = CGRectMake(0, 0, 100, 100);
    view.layer.cornerRadius = 50;
    view.clipsToBounds = YES;
    view.backgroundColor = [UIColor gg_colorWithR:53 G:174 B:220 alpha:1];
    [self.view insertSubview:view atIndex:0];
    return view;
}

- (UIButton *)xiubtn{
    if(!_xiuBtn){
        _xiuBtn = [[UIButton alloc]init];
        _xiuBtn.backgroundColor = [UIColor gg_colorWithR:53 G:174 B:220 alpha:1];
        _xiuBtn.layer.cornerRadius = 50;
        _xiuBtn.clipsToBounds = YES;
        [_xiuBtn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _xiuBtn;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
